#include <stdio.h>
#include "LRUcache.h"
void testFunc1()
{
    /*
        为了测试方便， key 和 value 是相同的
        capacity = 5
        puth a a
             b b
             c c
        printf
        find a
        printf
        push d d
        push e e

        push f f
        printf
    */
    printf("====================\n");
    printf("In Test One\n");
    LruCache *lru = newLruCache(5);

    cachePush(lru , 'a' , 'f');

    cachePush(lru , 'b' , 'b');

    cachePush(lru , 'c' , 'c');

    printCache(lru);
    Entrys *entry = getValueThroughKey(lru , 'a');
    printCache(lru);

    cachePush(lru , 'd' , 'd');

    cachePush(lru , 'e' , 'e');


    cachePush(lru , 'f' , 'f');
    printCache(lru);

}
void testFunc2()
{
     /*
        为了测试方便， key 和 value 是相同的
        capacity = 5
        puth a a
             b b
             c c
             d d
             e e
        print (e e->d d->c c->b b->a a)
       find e
       find d
       find c
       find b
       find a
       printf  (a a -> b b -> c c -> d d -> e )

    */
    printf("====================\n");
    printf("In Test Two\n");
    LruCache *lr = newLruCache(5);
    cachePush(lr , 'a' , 'a');

    cachePush(lr , 'b' , 'b');

    cachePush(lr , 'c' , 'c');

    cachePush(lr , 'd' , 'd');

    cachePush(lr , 'e' , 'e');

    printCache(lr);

    Entrys *entry = getValueThroughKey(lr , 'e');

    entry = getValueThroughKey(lr , 'd');

    entry = getValueThroughKey(lr , 'c');

    entry = getValueThroughKey(lr , 'b');

    entry = getValueThroughKey(lr , 'a');

    printCache(lr);
}
int main()
{
    testFunc1();
    testFunc2();

    return 0;
}
